<html>
<head><meta charset="utf-8"><title>Nested lint groups? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html">Nested lint groups?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211390579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211390579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211390579">(Sep 27 2020 at 01:03)</a>:</h4>
<p>For <a href="https://github.com/rust-lang/rust/pull/77242#issuecomment-699565095">https://github.com/rust-lang/rust/pull/77242#issuecomment-699565095</a> I want to split out <code>broken_intra_doc_links</code> into multiple lints in the same lint group. But <code>broken_intra_doc_links</code> is already in the <code>rustdoc</code> lint group. Is there a way to nest groups so that <code>rustdoc</code> enables <code>broken_intra_doc_links</code> and <code>broken_intra_doc_links</code> enables several other lints?</p>



<a name="211390584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211390584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211390584">(Sep 27 2020 at 01:03)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="118594">@ecstatic-morse</span></p>



<a name="211391111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211391111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211391111">(Sep 27 2020 at 01:18)</a>:</h4>
<p>looks like no, it goes through <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/context/struct.LintGroup.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/context/struct.LintGroup.html</a>, which requires a LintId, which doesn't allow for nesting LintGroups</p>



<a name="211391150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211391150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211391150">(Sep 27 2020 at 01:18)</a>:</h4>
<p>hmm, how hard would that be to add?</p>



<a name="211392074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392074">(Sep 27 2020 at 01:45)</a>:</h4>
<p>Thanks for considering this. Mostly I'm just excited to turn every <code>Type</code> into an intra-doc link in my <code>rustc</code> code.  Do we warn for intra-doc links between private items? Or just public-to-private? If it's the second maybe I should just be more careful about what's public.</p>
<p>I have no idea how difficult it would be to have arbitrarily nested lint groups. Perhaps there's some way to abuse lint aliasing to emulate an extra level?</p>



<a name="211392137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392137">(Sep 27 2020 at 01:46)</a>:</h4>
<p>just for public-to-private</p>



<a name="211392151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392151">(Sep 27 2020 at 01:47)</a>:</h4>
<blockquote>
<p>I have no idea how difficult it would be to have arbitrarily nested lint groups. Perhaps there's some way to abuse lint aliasing to emulate an extra level?</p>
</blockquote>
<p>I'm not sure that would work but let me try</p>



<a name="211392157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392157">(Sep 27 2020 at 01:47)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/77249">https://github.com/rust-lang/rust/pull/77249</a> fyi</p>



<a name="211392286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392286">(Sep 27 2020 at 01:50)</a>:</h4>
<blockquote>
<div class="codehilite"><pre><span></span><code>store.register_group_alias(&quot;broken_intra_doc_links&quot;, &quot;rustdoc&quot;);
</code></pre></div>


</blockquote>
<p>this seems like a bad idea <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="211392366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392366">(Sep 27 2020 at 01:52)</a>:</h4>
<p>I'll be honest, I think I'm going to work on <a href="https://github.com/rust-lang/rust/issues/77193">https://github.com/rust-lang/rust/issues/77193</a> instead</p>



<a name="211392370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392370">(Sep 27 2020 at 01:52)</a>:</h4>
<p>if someone else comes up with bright ideas let me know though</p>



<a name="211392516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392516">(Sep 27 2020 at 01:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Nested.20lint.20groups.3F/near/211392137">said</a>:</p>
<blockquote>
<p>just for public-to-private</p>
</blockquote>
<p>No worries. I'm actually a bit surprised that it didn't work, since that was a link from a method on a <code>pub</code> trait to a method on another <code>pub</code> trait in the same module.</p>



<a name="211392518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392518">(Sep 27 2020 at 01:56)</a>:</h4>
<p>hmm that seems like a rustdoc bug</p>



<a name="211392519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392519">(Sep 27 2020 at 01:56)</a>:</h4>
<p>let me look again at what failed</p>



<a name="211392575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392575">(Sep 27 2020 at 01:58)</a>:</h4>
<p><code>dataflow</code> has a lot of re-exporting going on, and I don't think the second trait is re-exported even though it appears in the signature of the method of the public trait. Might be that <code>rustdoc</code> has it correct but <code>rustc</code> doesn't.</p>



<a name="211392586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392586">(Sep 27 2020 at 01:58)</a>:</h4>
<p>There's some long-standing private-in-public bugs like this IIRC.</p>



<a name="211392589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392589">(Sep 27 2020 at 01:58)</a>:</h4>
<p>I'll try to reduce it.</p>



<a name="211392600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392600">(Sep 27 2020 at 01:59)</a>:</h4>
<p>this is going through rustc, so I wouldn't expect it to be different:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">                </span><span class="k">if</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">tcx</span><span class="p">.</span><span class="n">privacy_access_levels</span><span class="p">(</span><span class="n">LOCAL_CRATE</span><span class="p">).</span><span class="n">is_exported</span><span class="p">(</span><span class="n">hir_src</span><span class="p">)</span><span class="w"></span>
<span class="w">                    </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="o">!</span><span class="bp">self</span><span class="p">.</span><span class="n">cx</span><span class="p">.</span><span class="n">tcx</span><span class="p">.</span><span class="n">privacy_access_levels</span><span class="p">(</span><span class="n">LOCAL_CRATE</span><span class="p">).</span><span class="n">is_exported</span><span class="p">(</span><span class="n">hir_dst</span><span class="p">)</span><span class="w"></span>
<span class="w">                </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">privacy_error</span><span class="p">(</span><span class="n">cx</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">item</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">path_str</span><span class="p">,</span><span class="w"> </span><span class="n">dox</span><span class="p">,</span><span class="w"> </span><span class="n">link_range</span><span class="p">);</span><span class="w"></span>
<span class="w">                    </span><span class="k">return</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="211392749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392749">(Sep 27 2020 at 02:03)</a>:</h4>
<p>record for most hacky code of the night?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">            </span><span class="c1">// HACK: rustc_resolve thinks that `crate` is the crate currently being documented.</span>
<span class="w">            </span><span class="c1">// But rustdoc wants it to mean the crate this item was originally present in.</span>
<span class="w">            </span><span class="c1">// To work around this, remove it and resolve relative to the crate root instead.</span>
<span class="w">            </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">path_str</span><span class="p">.</span><span class="n">starts_with</span><span class="p">(</span><span class="s">"crate::"</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">use</span><span class="w"> </span><span class="n">rustc_span</span>::<span class="n">def_id</span>::<span class="n">CRATE_DEF_INDEX</span><span class="p">;</span><span class="w"></span>

<span class="w">                </span><span class="n">path_str</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">path_str</span><span class="p">[</span><span class="s">"crate::"</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="o">..</span><span class="p">];</span><span class="w"></span>
<span class="w">                </span><span class="n">module_id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DefId</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">krate</span>: <span class="nc">item</span><span class="p">.</span><span class="n">def_id</span><span class="p">.</span><span class="n">krate</span><span class="p">,</span><span class="w"> </span><span class="n">index</span>: <span class="nc">CRATE_DEF_INDEX</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="211392847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392847">(Sep 27 2020 at 02:05)</a>:</h4>
<p>of the night, surely</p>



<a name="211392914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392914">(Sep 27 2020 at 02:06)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=4668a806d06b0d3c4187310c9e7fe0dc">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=4668a806d06b0d3c4187310c9e7fe0dc</a></p>
<p>is the MCVE. <code>rustdoc</code> is correct here. The bug is in <code>rustc</code>. <code>B</code> isn't publicly-visible, but appears in the signature of <code>A::foo</code>.</p>



<a name="211392924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392924">(Sep 27 2020 at 02:06)</a>:</h4>
<p>I think usually we warn for cases like this. I'll open an issue.</p>



<a name="211392948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392948">(Sep 27 2020 at 02:08)</a>:</h4>
<p>Sorry for the trouble! As long as private-to-private links are supported, I don't know how urgent it is to split the lints.</p>



<a name="211392999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211392999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211392999">(Sep 27 2020 at 02:08)</a>:</h4>
<p>ehh, I think it makes sense to split them anyway</p>



<a name="211393006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393006">(Sep 27 2020 at 02:09)</a>:</h4>
<p>things like ambiguity errors should be split too IMO</p>



<a name="211393014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393014">(Sep 27 2020 at 02:09)</a>:</h4>
<p>then we can upgrade <code>broken_intra_doc_links</code> to deny-by-default and ambiguity would stay a warning</p>



<a name="211393079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393079">(Sep 27 2020 at 02:11)</a>:</h4>
<p>Sweet! I love this feature by the way. Thanks for pushing it over the finish line.</p>



<a name="211393085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393085">(Sep 27 2020 at 02:11)</a>:</h4>
<p>absolutely! I'm so excited it's finally going to be stable :D</p>



<a name="211393089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393089">(Sep 27 2020 at 02:11)</a>:</h4>
<p>I've spent like 3 months on it lol</p>



<a name="211393289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393289">(Sep 27 2020 at 02:16)</a>:</h4>
<p>oh god it got worse <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span> </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">            </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">path_str</span><span class="p">.</span><span class="n">starts_with</span><span class="p">(</span><span class="s">"crate::"</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">use</span><span class="w"> </span><span class="n">rustc_span</span>::<span class="n">def_id</span>::<span class="n">CRATE_DEF_INDEX</span><span class="p">;</span><span class="w"></span>

<span class="w">                </span><span class="c1">// HACK(jynelson): rustc_resolve thinks that `crate` is the crate currently being documented.</span>
<span class="w">                </span><span class="c1">// But rustdoc wants it to mean the crate this item was originally present in.</span>
<span class="w">                </span><span class="c1">// To work around this, remove it and resolve relative to the crate root instead.</span>
<span class="w">                </span><span class="c1">// HACK(jynelson)(2): If we just strip `crate::` then suddenly primitives become ambiguous</span>
<span class="w">                </span><span class="c1">// (consider `crate::char`). Instead, change it to `self::`. This works because 'self' is now the crate root.</span>
<span class="w">                </span><span class="n">resolved_self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">format</span><span class="o">!</span><span class="p">(</span><span class="s">"self::{}"</span><span class="p">,</span><span class="w"> </span><span class="n">path_str</span><span class="p">[</span><span class="s">"crate::"</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="o">..</span><span class="p">]);</span><span class="w"></span>
<span class="w">                </span><span class="n">path_str</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">resolved_self</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="n">module_id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DefId</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">krate</span>: <span class="nc">item</span><span class="p">.</span><span class="n">def_id</span><span class="p">.</span><span class="n">krate</span><span class="p">,</span><span class="w"> </span><span class="n">index</span>: <span class="nc">CRATE_DEF_INDEX</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="211393377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393377">(Sep 27 2020 at 02:19)</a>:</h4>
<p>Upon further investigation, my code is isomorphic to the following, so I think this is working as intended as far as <code>rustc</code> is concerned.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">private</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">Sealed</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">A</span>: <span class="nc">private</span>::<span class="n">Sealed</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// [`private::Sealed`]</span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="211393425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393425">(Sep 27 2020 at 02:20)</a>:</h4>
<p>New lint: one <code>HACK</code> per-person, per-line <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="211393430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393430">(Sep 27 2020 at 02:20)</a>:</h4>
<p>it's multiple <em>lines</em></p>



<a name="211393438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Nested%20lint%20groups%3F/near/211393438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Nested.20lint.20groups.3F.html#211393438">(Sep 27 2020 at 02:21)</a>:</h4>
<p>maybe per scope lmao</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>